package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.AreaMapper;
import com.iot.manage.pojo.Area;
import com.iot.manage.pojo.Device;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AreaService {

    @Autowired
    private AreaMapper areaMapper;

    public List<Area> findAreaList(String query, int pagenum, int pagesize) {
        return areaMapper.findAreaList(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countAreaList(String query) {
        return areaMapper.countAreaList(query);
    }

    public void addArea(JSONObject params) {
        areaMapper.addArea(params);
    }

    public Area findAreaByIdOrName(String params) {
        return areaMapper.findAreaByIdOrName(params);
    }

    public void updateAreaInfo(JSONObject params) {
        areaMapper.updateAreaInfo(params);
    }

    public void deleteAreaById(String areaId) {
        areaMapper.deleteAreaById(areaId);
    }

    public List<Device> findAllAllotDevice() {
        return areaMapper.findAllAllotDevice();
    }

    public List<String> findAllotDeviceById(String areaId) {
        return areaMapper.findAllotDeviceById(areaId);
    }

    public void deleteDeviceOfAllotById(String areaId) {
        areaMapper.deleteDeviceOfAllotById(areaId);
    }

    public void addDeviceOfAllotById(List<Map<String, String>> list) {
        areaMapper.addDeviceOfAllotById(list);
    }

    public void deleteRelevancyAppById(String areaId) {
        areaMapper.deleteRelevancyAppById(areaId);
    }

    public void deleteRelevancyDeviceById(String areaId) {
        areaMapper.deleteRelevancyDeviceById(areaId);
    }
}
